package com.google.android.material.tabs;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.text.Layout;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.a;
import androidx.appcompat.widget.y0;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import b.f.l.q;
import b.f.l.s;
import c.b.a.b.k;
import c.b.a.b.l;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;

@ViewPager.e
public class TabLayout extends HorizontalScrollView {
    private static final b.f.k.e<g> P = new b.f.k.g(16);
    int A;
    boolean B;
    boolean C;
    boolean D;
    private c E;
    private final ArrayList<c> F;
    private c G;
    private ValueAnimator H;
    ViewPager I;
    private androidx.viewpager.widget.a J;
    private DataSetObserver K;
    private h L;
    private b M;
    private boolean N;
    private final b.f.k.e<i> O;

    /* renamed from: b  reason: collision with root package name */
    private final ArrayList<g> f2360b;

    /* renamed from: c  reason: collision with root package name */
    private g f2361c;
    /* access modifiers changed from: private */

    /* renamed from: d  reason: collision with root package name */
    public final RectF f2362d;
    private final f e;
    int f;
    int g;
    int h;
    int i;
    int j;
    ColorStateList k;
    ColorStateList l;
    ColorStateList m;
    Drawable n;
    PorterDuff.Mode o;
    float p;
    float q;
    final int r;
    int s;
    private final int t;
    private final int u;
    private final int v;
    private int w;
    int x;
    int y;
    int z;

    class a implements ValueAnimator.AnimatorUpdateListener {
        a() {
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            TabLayout.this.scrollTo(((Integer) valueAnimator.getAnimatedValue()).intValue(), 0);
        }
    }

    private class b implements ViewPager.i {

        /* renamed from: a  reason: collision with root package name */
        private boolean f2364a;

        b() {
        }

        public void a(ViewPager viewPager, androidx.viewpager.widget.a aVar, androidx.viewpager.widget.a aVar2) {
            TabLayout tabLayout = TabLayout.this;
            if (tabLayout.I == viewPager) {
                tabLayout.D(aVar2, this.f2364a);
            }
        }

        /* access modifiers changed from: package-private */
        public void b(boolean z) {
            this.f2364a = z;
        }
    }

    @Deprecated
    public interface c<T extends g> {
        void a(T t);

        void b(T t);

        void c(T t);
    }

    public interface d extends c<g> {
    }

    private class e extends DataSetObserver {
        e() {
        }

        public void onChanged() {
            TabLayout.this.w();
        }

        public void onInvalidated() {
            TabLayout.this.w();
        }
    }

    private class f extends LinearLayout {

        /* renamed from: b  reason: collision with root package name */
        private int f2367b;

        /* renamed from: c  reason: collision with root package name */
        private final Paint f2368c;

        /* renamed from: d  reason: collision with root package name */
        private final GradientDrawable f2369d;
        int e = -1;
        float f;
        private int g = -1;
        private int h = -1;
        private int i = -1;
        private ValueAnimator j;

        class a implements ValueAnimator.AnimatorUpdateListener {

            /* renamed from: a  reason: collision with root package name */
            final /* synthetic */ int f2370a;

            /* renamed from: b  reason: collision with root package name */
            final /* synthetic */ int f2371b;

            /* renamed from: c  reason: collision with root package name */
            final /* synthetic */ int f2372c;

            /* renamed from: d  reason: collision with root package name */
            final /* synthetic */ int f2373d;

            a(int i, int i2, int i3, int i4) {
                this.f2370a = i;
                this.f2371b = i2;
                this.f2372c = i3;
                this.f2373d = i4;
            }

            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float animatedFraction = valueAnimator.getAnimatedFraction();
                f.this.d(c.b.a.b.m.a.b(this.f2370a, this.f2371b, animatedFraction), c.b.a.b.m.a.b(this.f2372c, this.f2373d, animatedFraction));
            }
        }

        class b extends AnimatorListenerAdapter {

            /* renamed from: a  reason: collision with root package name */
            final /* synthetic */ int f2374a;

            b(int i) {
                this.f2374a = i;
            }

            public void onAnimationEnd(Animator animator) {
                f fVar = f.this;
                fVar.e = this.f2374a;
                fVar.f = 0.0f;
            }
        }

        f(Context context) {
            super(context);
            setWillNotDraw(false);
            this.f2368c = new Paint();
            this.f2369d = new GradientDrawable();
        }

        private void b(i iVar, RectF rectF) {
            int b2 = iVar.getContentWidth();
            int a2 = (int) com.google.android.material.internal.h.a(getContext(), 24);
            if (b2 < a2) {
                b2 = a2;
            }
            int left = (iVar.getLeft() + iVar.getRight()) / 2;
            int i2 = b2 / 2;
            rectF.set((float) (left - i2), 0.0f, (float) (left + i2), 0.0f);
        }

        private void h() {
            int i2;
            int i3;
            View childAt = getChildAt(this.e);
            if (childAt == null || childAt.getWidth() <= 0) {
                i3 = -1;
                i2 = -1;
            } else {
                i3 = childAt.getLeft();
                i2 = childAt.getRight();
                TabLayout tabLayout = TabLayout.this;
                if (!tabLayout.C && (childAt instanceof i)) {
                    b((i) childAt, tabLayout.f2362d);
                    i3 = (int) TabLayout.this.f2362d.left;
                    i2 = (int) TabLayout.this.f2362d.right;
                }
                if (this.f > 0.0f && this.e < getChildCount() - 1) {
                    View childAt2 = getChildAt(this.e + 1);
                    int left = childAt2.getLeft();
                    int right = childAt2.getRight();
                    TabLayout tabLayout2 = TabLayout.this;
                    if (!tabLayout2.C && (childAt2 instanceof i)) {
                        b((i) childAt2, tabLayout2.f2362d);
                        left = (int) TabLayout.this.f2362d.left;
                        right = (int) TabLayout.this.f2362d.right;
                    }
                    float f2 = this.f;
                    i3 = (int) ((((float) left) * f2) + ((1.0f - f2) * ((float) i3)));
                    i2 = (int) ((((float) right) * f2) + ((1.0f - f2) * ((float) i2)));
                }
            }
            d(i3, i2);
        }

        /* access modifiers changed from: package-private */
        public void a(int i2, int i3) {
            ValueAnimator valueAnimator = this.j;
            if (valueAnimator != null && valueAnimator.isRunning()) {
                this.j.cancel();
            }
            View childAt = getChildAt(i2);
            if (childAt == null) {
                h();
                return;
            }
            int left = childAt.getLeft();
            int right = childAt.getRight();
            TabLayout tabLayout = TabLayout.this;
            if (!tabLayout.C && (childAt instanceof i)) {
                b((i) childAt, tabLayout.f2362d);
                left = (int) TabLayout.this.f2362d.left;
                right = (int) TabLayout.this.f2362d.right;
            }
            int i4 = left;
            int i5 = right;
            int i6 = this.h;
            int i7 = this.i;
            if (i6 != i4 || i7 != i5) {
                ValueAnimator valueAnimator2 = new ValueAnimator();
                this.j = valueAnimator2;
                valueAnimator2.setInterpolator(c.b.a.b.m.a.f1875b);
                valueAnimator2.setDuration((long) i3);
                valueAnimator2.setFloatValues(new float[]{0.0f, 1.0f});
                valueAnimator2.addUpdateListener(new a(i6, i4, i7, i5));
                valueAnimator2.addListener(new b(i2));
                valueAnimator2.start();
            }
        }

        /* access modifiers changed from: package-private */
        public boolean c() {
            int childCount = getChildCount();
            for (int i2 = 0; i2 < childCount; i2++) {
                if (getChildAt(i2).getWidth() <= 0) {
                    return true;
                }
            }
            return false;
        }

        /* access modifiers changed from: package-private */
        public void d(int i2, int i3) {
            if (i2 != this.h || i3 != this.i) {
                this.h = i2;
                this.i = i3;
                s.W(this);
            }
        }

        /* JADX WARNING: Removed duplicated region for block: B:24:0x0049  */
        /* JADX WARNING: Removed duplicated region for block: B:27:0x005a  */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public void draw(android.graphics.Canvas r6) {
            /*
                r5 = this;
                com.google.android.material.tabs.TabLayout r0 = com.google.android.material.tabs.TabLayout.this
                android.graphics.drawable.Drawable r0 = r0.n
                r1 = 0
                if (r0 == 0) goto L_0x000c
                int r0 = r0.getIntrinsicHeight()
                goto L_0x000d
            L_0x000c:
                r0 = 0
            L_0x000d:
                int r2 = r5.f2367b
                if (r2 < 0) goto L_0x0012
                r0 = r2
            L_0x0012:
                com.google.android.material.tabs.TabLayout r2 = com.google.android.material.tabs.TabLayout.this
                int r2 = r2.z
                if (r2 == 0) goto L_0x0031
                r3 = 1
                r4 = 2
                if (r2 == r3) goto L_0x0023
                if (r2 == r4) goto L_0x003a
                r0 = 3
                if (r2 == r0) goto L_0x0036
                r0 = 0
                goto L_0x003a
            L_0x0023:
                int r1 = r5.getHeight()
                int r1 = r1 - r0
                int r1 = r1 / r4
                int r2 = r5.getHeight()
                int r2 = r2 + r0
                int r0 = r2 / 2
                goto L_0x003a
            L_0x0031:
                int r1 = r5.getHeight()
                int r1 = r1 - r0
            L_0x0036:
                int r0 = r5.getHeight()
            L_0x003a:
                int r2 = r5.h
                if (r2 < 0) goto L_0x0070
                int r3 = r5.i
                if (r3 <= r2) goto L_0x0070
                com.google.android.material.tabs.TabLayout r2 = com.google.android.material.tabs.TabLayout.this
                android.graphics.drawable.Drawable r2 = r2.n
                if (r2 == 0) goto L_0x0049
                goto L_0x004b
            L_0x0049:
                android.graphics.drawable.GradientDrawable r2 = r5.f2369d
            L_0x004b:
                android.graphics.drawable.Drawable r2 = androidx.core.graphics.drawable.a.r(r2)
                int r3 = r5.h
                int r4 = r5.i
                r2.setBounds(r3, r1, r4, r0)
                android.graphics.Paint r0 = r5.f2368c
                if (r0 == 0) goto L_0x006d
                int r1 = android.os.Build.VERSION.SDK_INT
                r3 = 21
                int r0 = r0.getColor()
                if (r1 != r3) goto L_0x006a
                android.graphics.PorterDuff$Mode r1 = android.graphics.PorterDuff.Mode.SRC_IN
                r2.setColorFilter(r0, r1)
                goto L_0x006d
            L_0x006a:
                androidx.core.graphics.drawable.a.n(r2, r0)
            L_0x006d:
                r2.draw(r6)
            L_0x0070:
                super.draw(r6)
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.tabs.TabLayout.f.draw(android.graphics.Canvas):void");
        }

        /* access modifiers changed from: package-private */
        public void e(int i2, float f2) {
            ValueAnimator valueAnimator = this.j;
            if (valueAnimator != null && valueAnimator.isRunning()) {
                this.j.cancel();
            }
            this.e = i2;
            this.f = f2;
            h();
        }

        /* access modifiers changed from: package-private */
        public void f(int i2) {
            if (this.f2368c.getColor() != i2) {
                this.f2368c.setColor(i2);
                s.W(this);
            }
        }

        /* access modifiers changed from: package-private */
        public void g(int i2) {
            if (this.f2367b != i2) {
                this.f2367b = i2;
                s.W(this);
            }
        }

        /* access modifiers changed from: protected */
        public void onLayout(boolean z, int i2, int i3, int i4, int i5) {
            super.onLayout(z, i2, i3, i4, i5);
            ValueAnimator valueAnimator = this.j;
            if (valueAnimator == null || !valueAnimator.isRunning()) {
                h();
                return;
            }
            this.j.cancel();
            a(this.e, Math.round((1.0f - this.j.getAnimatedFraction()) * ((float) this.j.getDuration())));
        }

        /* access modifiers changed from: protected */
        public void onMeasure(int i2, int i3) {
            super.onMeasure(i2, i3);
            if (View.MeasureSpec.getMode(i2) == 1073741824) {
                TabLayout tabLayout = TabLayout.this;
                boolean z = true;
                if (tabLayout.x == 1 || tabLayout.A == 2) {
                    int childCount = getChildCount();
                    int i4 = 0;
                    for (int i5 = 0; i5 < childCount; i5++) {
                        View childAt = getChildAt(i5);
                        if (childAt.getVisibility() == 0) {
                            i4 = Math.max(i4, childAt.getMeasuredWidth());
                        }
                    }
                    if (i4 > 0) {
                        if (i4 * childCount <= getMeasuredWidth() - (((int) com.google.android.material.internal.h.a(getContext(), 16)) * 2)) {
                            boolean z2 = false;
                            for (int i6 = 0; i6 < childCount; i6++) {
                                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) getChildAt(i6).getLayoutParams();
                                if (layoutParams.width != i4 || layoutParams.weight != 0.0f) {
                                    layoutParams.width = i4;
                                    layoutParams.weight = 0.0f;
                                    z2 = true;
                                }
                            }
                            z = z2;
                        } else {
                            TabLayout tabLayout2 = TabLayout.this;
                            tabLayout2.x = 0;
                            tabLayout2.K(false);
                        }
                        if (z) {
                            super.onMeasure(i2, i3);
                        }
                    }
                }
            }
        }

        public void onRtlPropertiesChanged(int i2) {
            super.onRtlPropertiesChanged(i2);
            if (Build.VERSION.SDK_INT < 23 && this.g != i2) {
                requestLayout();
                this.g = i2;
            }
        }
    }

    public static class g {

        /* renamed from: a  reason: collision with root package name */
        private Drawable f2376a;
        /* access modifiers changed from: private */

        /* renamed from: b  reason: collision with root package name */
        public CharSequence f2377b;
        /* access modifiers changed from: private */

        /* renamed from: c  reason: collision with root package name */
        public CharSequence f2378c;

        /* renamed from: d  reason: collision with root package name */
        private int f2379d = -1;
        private View e;
        /* access modifiers changed from: private */
        public int f = 1;
        public TabLayout g;
        public i h;

        public View d() {
            return this.e;
        }

        public Drawable e() {
            return this.f2376a;
        }

        public int f() {
            return this.f2379d;
        }

        public int g() {
            return this.f;
        }

        public CharSequence h() {
            return this.f2377b;
        }

        public boolean i() {
            TabLayout tabLayout = this.g;
            if (tabLayout != null) {
                return tabLayout.getSelectedTabPosition() == this.f2379d;
            }
            throw new IllegalArgumentException("Tab not attached to a TabLayout");
        }

        /* access modifiers changed from: package-private */
        public void j() {
            this.g = null;
            this.h = null;
            this.f2376a = null;
            this.f2377b = null;
            this.f2378c = null;
            this.f2379d = -1;
            this.e = null;
        }

        public void k() {
            TabLayout tabLayout = this.g;
            if (tabLayout != null) {
                tabLayout.B(this);
                return;
            }
            throw new IllegalArgumentException("Tab not attached to a TabLayout");
        }

        public g l(CharSequence charSequence) {
            this.f2378c = charSequence;
            r();
            return this;
        }

        public g m(int i) {
            n(LayoutInflater.from(this.h.getContext()).inflate(i, this.h, false));
            return this;
        }

        public g n(View view) {
            this.e = view;
            r();
            return this;
        }

        public g o(Drawable drawable) {
            this.f2376a = drawable;
            TabLayout tabLayout = this.g;
            if (tabLayout.x == 1 || tabLayout.A == 2) {
                this.g.K(true);
            }
            r();
            if (c.b.a.b.n.b.f1901a && this.h.l() && this.h.f.isVisible()) {
                this.h.invalidate();
            }
            return this;
        }

        /* access modifiers changed from: package-private */
        public void p(int i) {
            this.f2379d = i;
        }

        public g q(CharSequence charSequence) {
            if (TextUtils.isEmpty(this.f2378c) && !TextUtils.isEmpty(charSequence)) {
                this.h.setContentDescription(charSequence);
            }
            this.f2377b = charSequence;
            r();
            return this;
        }

        /* access modifiers changed from: package-private */
        public void r() {
            i iVar = this.h;
            if (iVar != null) {
                iVar.t();
            }
        }
    }

    public static class h implements ViewPager.j {

        /* renamed from: a  reason: collision with root package name */
        private final WeakReference<TabLayout> f2380a;

        /* renamed from: b  reason: collision with root package name */
        private int f2381b;

        /* renamed from: c  reason: collision with root package name */
        private int f2382c;

        public h(TabLayout tabLayout) {
            this.f2380a = new WeakReference<>(tabLayout);
        }

        public void a(int i, float f, int i2) {
            TabLayout tabLayout = (TabLayout) this.f2380a.get();
            if (tabLayout != null) {
                boolean z = false;
                boolean z2 = this.f2382c != 2 || this.f2381b == 1;
                if (!(this.f2382c == 2 && this.f2381b == 0)) {
                    z = true;
                }
                tabLayout.F(i, f, z2, z);
            }
        }

        public void b(int i) {
            this.f2381b = this.f2382c;
            this.f2382c = i;
        }

        public void c(int i) {
            TabLayout tabLayout = (TabLayout) this.f2380a.get();
            if (tabLayout != null && tabLayout.getSelectedTabPosition() != i && i < tabLayout.getTabCount()) {
                int i2 = this.f2382c;
                tabLayout.C(tabLayout.u(i), i2 == 0 || (i2 == 2 && this.f2381b == 0));
            }
        }

        /* access modifiers changed from: package-private */
        public void d() {
            this.f2382c = 0;
            this.f2381b = 0;
        }
    }

    public final class i extends LinearLayout {

        /* renamed from: b  reason: collision with root package name */
        private g f2383b;

        /* renamed from: c  reason: collision with root package name */
        private TextView f2384c;

        /* renamed from: d  reason: collision with root package name */
        private ImageView f2385d;
        private View e;
        /* access modifiers changed from: private */
        public c.b.a.b.n.a f;
        private View g;
        private TextView h;
        private ImageView i;
        private Drawable j;
        private int k = 2;

        class a implements View.OnLayoutChangeListener {

            /* renamed from: a  reason: collision with root package name */
            final /* synthetic */ View f2386a;

            a(View view) {
                this.f2386a = view;
            }

            public void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
                if (this.f2386a.getVisibility() == 0) {
                    i.this.s(this.f2386a);
                }
            }
        }

        public i(Context context) {
            super(context);
            u(context);
            s.r0(this, TabLayout.this.f, TabLayout.this.g, TabLayout.this.h, TabLayout.this.i);
            setGravity(17);
            setOrientation(TabLayout.this.B ^ true ? 1 : 0);
            setClickable(true);
            s.s0(this, q.b(getContext(), 1002));
            s.e0(this, (b.f.l.a) null);
        }

        private void g(View view) {
            if (view != null) {
                view.addOnLayoutChangeListener(new a(view));
            }
        }

        private c.b.a.b.n.a getBadge() {
            return this.f;
        }

        /* access modifiers changed from: private */
        public int getContentWidth() {
            View[] viewArr = {this.f2384c, this.f2385d, this.g};
            int i2 = 0;
            int i3 = 0;
            boolean z = false;
            for (int i4 = 0; i4 < 3; i4++) {
                View view = viewArr[i4];
                if (view != null && view.getVisibility() == 0) {
                    i3 = z ? Math.min(i3, view.getLeft()) : view.getLeft();
                    i2 = z ? Math.max(i2, view.getRight()) : view.getRight();
                    z = true;
                }
            }
            return i2 - i3;
        }

        private c.b.a.b.n.a getOrCreateBadge() {
            if (this.f == null) {
                this.f = c.b.a.b.n.a.c(getContext());
            }
            r();
            c.b.a.b.n.a aVar = this.f;
            if (aVar != null) {
                return aVar;
            }
            throw new IllegalStateException("Unable to create badge");
        }

        private float h(Layout layout, int i2, float f2) {
            return layout.getLineWidth(i2) * (f2 / layout.getPaint().getTextSize());
        }

        private FrameLayout i() {
            FrameLayout frameLayout = new FrameLayout(getContext());
            frameLayout.setLayoutParams(new FrameLayout.LayoutParams(-2, -2));
            return frameLayout;
        }

        /* access modifiers changed from: private */
        public void j(Canvas canvas) {
            Drawable drawable = this.j;
            if (drawable != null) {
                drawable.setBounds(getLeft(), getTop(), getRight(), getBottom());
                this.j.draw(canvas);
            }
        }

        private FrameLayout k(View view) {
            if ((view == this.f2385d || view == this.f2384c) && c.b.a.b.n.b.f1901a) {
                return (FrameLayout) view.getParent();
            }
            return null;
        }

        /* access modifiers changed from: private */
        public boolean l() {
            return this.f != null;
        }

        private void m() {
            ViewGroup viewGroup;
            if (c.b.a.b.n.b.f1901a) {
                viewGroup = i();
                addView(viewGroup, 0);
            } else {
                viewGroup = this;
            }
            ImageView imageView = (ImageView) LayoutInflater.from(getContext()).inflate(c.b.a.b.h.design_layout_tab_icon, viewGroup, false);
            this.f2385d = imageView;
            viewGroup.addView(imageView, 0);
        }

        private void n() {
            ViewGroup viewGroup;
            if (c.b.a.b.n.b.f1901a) {
                viewGroup = i();
                addView(viewGroup);
            } else {
                viewGroup = this;
            }
            TextView textView = (TextView) LayoutInflater.from(getContext()).inflate(c.b.a.b.h.design_layout_tab_text, viewGroup, false);
            this.f2384c = textView;
            viewGroup.addView(textView);
        }

        private void p(View view) {
            if (l() && view != null) {
                setClipChildren(false);
                setClipToPadding(false);
                c.b.a.b.n.b.a(this.f, view, k(view));
                this.e = view;
            }
        }

        private void q() {
            if (l() && this.e != null) {
                setClipChildren(true);
                setClipToPadding(true);
                c.b.a.b.n.a aVar = this.f;
                View view = this.e;
                c.b.a.b.n.b.b(aVar, view, k(view));
                this.e = null;
            }
        }

        private void r() {
            g gVar;
            View view;
            View view2;
            g gVar2;
            if (l()) {
                if (this.g == null) {
                    if (this.f2385d != null && (gVar2 = this.f2383b) != null && gVar2.e() != null) {
                        View view3 = this.e;
                        view = this.f2385d;
                        if (view3 != view) {
                            q();
                            view2 = this.f2385d;
                        }
                        s(view);
                        return;
                    } else if (!(this.f2384c == null || (gVar = this.f2383b) == null || gVar.g() != 1)) {
                        View view4 = this.e;
                        view = this.f2384c;
                        if (view4 != view) {
                            q();
                            view2 = this.f2384c;
                        }
                        s(view);
                        return;
                    }
                    p(view2);
                    return;
                }
                q();
            }
        }

        /* access modifiers changed from: private */
        public void s(View view) {
            if (l() && view == this.e) {
                c.b.a.b.n.b.c(this.f, view, k(view));
            }
        }

        /* JADX WARNING: type inference failed for: r2v3, types: [android.graphics.drawable.LayerDrawable] */
        /* JADX WARNING: type inference failed for: r0v3, types: [android.graphics.drawable.RippleDrawable] */
        /* access modifiers changed from: private */
        /* JADX WARNING: Multi-variable type inference failed */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public void u(android.content.Context r7) {
            /*
                r6 = this;
                com.google.android.material.tabs.TabLayout r0 = com.google.android.material.tabs.TabLayout.this
                int r0 = r0.r
                r1 = 0
                if (r0 == 0) goto L_0x001f
                android.graphics.drawable.Drawable r7 = b.a.k.a.a.d(r7, r0)
                r6.j = r7
                if (r7 == 0) goto L_0x0021
                boolean r7 = r7.isStateful()
                if (r7 == 0) goto L_0x0021
                android.graphics.drawable.Drawable r7 = r6.j
                int[] r0 = r6.getDrawableState()
                r7.setState(r0)
                goto L_0x0021
            L_0x001f:
                r6.j = r1
            L_0x0021:
                android.graphics.drawable.GradientDrawable r7 = new android.graphics.drawable.GradientDrawable
                r7.<init>()
                r0 = 0
                r7.setColor(r0)
                com.google.android.material.tabs.TabLayout r2 = com.google.android.material.tabs.TabLayout.this
                android.content.res.ColorStateList r2 = r2.m
                if (r2 == 0) goto L_0x0078
                android.graphics.drawable.GradientDrawable r2 = new android.graphics.drawable.GradientDrawable
                r2.<init>()
                r3 = 925353388(0x3727c5ac, float:1.0E-5)
                r2.setCornerRadius(r3)
                r3 = -1
                r2.setColor(r3)
                com.google.android.material.tabs.TabLayout r3 = com.google.android.material.tabs.TabLayout.this
                android.content.res.ColorStateList r3 = r3.m
                android.content.res.ColorStateList r3 = c.b.a.b.a0.b.a(r3)
                int r4 = android.os.Build.VERSION.SDK_INT
                r5 = 21
                if (r4 < r5) goto L_0x0063
                android.graphics.drawable.RippleDrawable r0 = new android.graphics.drawable.RippleDrawable
                com.google.android.material.tabs.TabLayout r4 = com.google.android.material.tabs.TabLayout.this
                boolean r4 = r4.D
                if (r4 == 0) goto L_0x0056
                r7 = r1
            L_0x0056:
                com.google.android.material.tabs.TabLayout r4 = com.google.android.material.tabs.TabLayout.this
                boolean r4 = r4.D
                if (r4 == 0) goto L_0x005d
                goto L_0x005e
            L_0x005d:
                r1 = r2
            L_0x005e:
                r0.<init>(r3, r7, r1)
                r7 = r0
                goto L_0x0078
            L_0x0063:
                android.graphics.drawable.Drawable r1 = androidx.core.graphics.drawable.a.r(r2)
                androidx.core.graphics.drawable.a.o(r1, r3)
                android.graphics.drawable.LayerDrawable r2 = new android.graphics.drawable.LayerDrawable
                r3 = 2
                android.graphics.drawable.Drawable[] r3 = new android.graphics.drawable.Drawable[r3]
                r3[r0] = r7
                r7 = 1
                r3[r7] = r1
                r2.<init>(r3)
                r7 = r2
            L_0x0078:
                b.f.l.s.h0(r6, r7)
                com.google.android.material.tabs.TabLayout r7 = com.google.android.material.tabs.TabLayout.this
                r7.invalidate()
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.tabs.TabLayout.i.u(android.content.Context):void");
        }

        private void w(TextView textView, ImageView imageView) {
            g gVar = this.f2383b;
            CharSequence charSequence = null;
            Drawable mutate = (gVar == null || gVar.e() == null) ? null : androidx.core.graphics.drawable.a.r(this.f2383b.e()).mutate();
            g gVar2 = this.f2383b;
            CharSequence h2 = gVar2 != null ? gVar2.h() : null;
            if (imageView != null) {
                if (mutate != null) {
                    imageView.setImageDrawable(mutate);
                    imageView.setVisibility(0);
                    setVisibility(0);
                } else {
                    imageView.setVisibility(8);
                    imageView.setImageDrawable((Drawable) null);
                }
            }
            boolean z = !TextUtils.isEmpty(h2);
            if (textView != null) {
                if (z) {
                    textView.setText(h2);
                    if (this.f2383b.f == 1) {
                        textView.setVisibility(0);
                    } else {
                        textView.setVisibility(8);
                    }
                    setVisibility(0);
                } else {
                    textView.setVisibility(8);
                    textView.setText((CharSequence) null);
                }
            }
            if (imageView != null) {
                ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) imageView.getLayoutParams();
                int a2 = (!z || imageView.getVisibility() != 0) ? 0 : (int) com.google.android.material.internal.h.a(getContext(), 8);
                if (TabLayout.this.B) {
                    if (a2 != b.f.l.f.a(marginLayoutParams)) {
                        b.f.l.f.c(marginLayoutParams, a2);
                        marginLayoutParams.bottomMargin = 0;
                    }
                } else if (a2 != marginLayoutParams.bottomMargin) {
                    marginLayoutParams.bottomMargin = a2;
                    b.f.l.f.c(marginLayoutParams, 0);
                }
                imageView.setLayoutParams(marginLayoutParams);
                imageView.requestLayout();
            }
            g gVar3 = this.f2383b;
            CharSequence a3 = gVar3 != null ? gVar3.f2378c : null;
            if (!z) {
                charSequence = a3;
            }
            y0.a(this, charSequence);
        }

        /* access modifiers changed from: protected */
        public void drawableStateChanged() {
            super.drawableStateChanged();
            int[] drawableState = getDrawableState();
            Drawable drawable = this.j;
            boolean z = false;
            if (drawable != null && drawable.isStateful()) {
                z = false | this.j.setState(drawableState);
            }
            if (z) {
                invalidate();
                TabLayout.this.invalidate();
            }
        }

        public g getTab() {
            return this.f2383b;
        }

        /* access modifiers changed from: package-private */
        public void o() {
            setTab((g) null);
            setSelected(false);
        }

        public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
            super.onInitializeAccessibilityEvent(accessibilityEvent);
            accessibilityEvent.setClassName(a.c.class.getName());
        }

        @TargetApi(14)
        public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
            super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
            accessibilityNodeInfo.setClassName(a.c.class.getName());
            c.b.a.b.n.a aVar = this.f;
            if (aVar != null && aVar.isVisible()) {
                CharSequence contentDescription = getContentDescription();
                accessibilityNodeInfo.setContentDescription(contentDescription + ", " + this.f.g());
            }
        }

        public void onMeasure(int i2, int i3) {
            Layout layout;
            int size = View.MeasureSpec.getSize(i2);
            int mode = View.MeasureSpec.getMode(i2);
            int tabMaxWidth = TabLayout.this.getTabMaxWidth();
            if (tabMaxWidth > 0 && (mode == 0 || size > tabMaxWidth)) {
                i2 = View.MeasureSpec.makeMeasureSpec(TabLayout.this.s, RecyclerView.UNDEFINED_DURATION);
            }
            super.onMeasure(i2, i3);
            if (this.f2384c != null) {
                float f2 = TabLayout.this.p;
                int i4 = this.k;
                ImageView imageView = this.f2385d;
                boolean z = true;
                if (imageView == null || imageView.getVisibility() != 0) {
                    TextView textView = this.f2384c;
                    if (textView != null && textView.getLineCount() > 1) {
                        f2 = TabLayout.this.q;
                    }
                } else {
                    i4 = 1;
                }
                float textSize = this.f2384c.getTextSize();
                int lineCount = this.f2384c.getLineCount();
                int d2 = androidx.core.widget.i.d(this.f2384c);
                int i5 = (f2 > textSize ? 1 : (f2 == textSize ? 0 : -1));
                if (i5 != 0 || (d2 >= 0 && i4 != d2)) {
                    if (TabLayout.this.A == 1 && i5 > 0 && lineCount == 1 && ((layout = this.f2384c.getLayout()) == null || h(layout, 0, f2) > ((float) ((getMeasuredWidth() - getPaddingLeft()) - getPaddingRight())))) {
                        z = false;
                    }
                    if (z) {
                        this.f2384c.setTextSize(0, f2);
                        this.f2384c.setMaxLines(i4);
                        super.onMeasure(i2, i3);
                    }
                }
            }
        }

        public boolean performClick() {
            boolean performClick = super.performClick();
            if (this.f2383b == null) {
                return performClick;
            }
            if (!performClick) {
                playSoundEffect(0);
            }
            this.f2383b.k();
            return true;
        }

        public void setSelected(boolean z) {
            boolean z2 = isSelected() != z;
            super.setSelected(z);
            if (z2 && z && Build.VERSION.SDK_INT < 16) {
                sendAccessibilityEvent(4);
            }
            TextView textView = this.f2384c;
            if (textView != null) {
                textView.setSelected(z);
            }
            ImageView imageView = this.f2385d;
            if (imageView != null) {
                imageView.setSelected(z);
            }
            View view = this.g;
            if (view != null) {
                view.setSelected(z);
            }
        }

        /* access modifiers changed from: package-private */
        public void setTab(g gVar) {
            if (gVar != this.f2383b) {
                this.f2383b = gVar;
                t();
            }
        }

        /* access modifiers changed from: package-private */
        public final void t() {
            g gVar = this.f2383b;
            Drawable drawable = null;
            View d2 = gVar != null ? gVar.d() : null;
            if (d2 != null) {
                ViewParent parent = d2.getParent();
                if (parent != this) {
                    if (parent != null) {
                        ((ViewGroup) parent).removeView(d2);
                    }
                    addView(d2);
                }
                this.g = d2;
                TextView textView = this.f2384c;
                if (textView != null) {
                    textView.setVisibility(8);
                }
                ImageView imageView = this.f2385d;
                if (imageView != null) {
                    imageView.setVisibility(8);
                    this.f2385d.setImageDrawable((Drawable) null);
                }
                TextView textView2 = (TextView) d2.findViewById(16908308);
                this.h = textView2;
                if (textView2 != null) {
                    this.k = androidx.core.widget.i.d(textView2);
                }
                this.i = (ImageView) d2.findViewById(16908294);
            } else {
                View view = this.g;
                if (view != null) {
                    removeView(view);
                    this.g = null;
                }
                this.h = null;
                this.i = null;
            }
            if (this.g == null) {
                if (this.f2385d == null) {
                    m();
                }
                if (!(gVar == null || gVar.e() == null)) {
                    drawable = androidx.core.graphics.drawable.a.r(gVar.e()).mutate();
                }
                if (drawable != null) {
                    androidx.core.graphics.drawable.a.o(drawable, TabLayout.this.l);
                    PorterDuff.Mode mode = TabLayout.this.o;
                    if (mode != null) {
                        androidx.core.graphics.drawable.a.p(drawable, mode);
                    }
                }
                if (this.f2384c == null) {
                    n();
                    this.k = androidx.core.widget.i.d(this.f2384c);
                }
                androidx.core.widget.i.q(this.f2384c, TabLayout.this.j);
                ColorStateList colorStateList = TabLayout.this.k;
                if (colorStateList != null) {
                    this.f2384c.setTextColor(colorStateList);
                }
                w(this.f2384c, this.f2385d);
                r();
                g(this.f2385d);
                g(this.f2384c);
            } else if (!(this.h == null && this.i == null)) {
                w(this.h, this.i);
            }
            if (gVar != null && !TextUtils.isEmpty(gVar.f2378c)) {
                setContentDescription(gVar.f2378c);
            }
            setSelected(gVar != null && gVar.i());
        }

        /* access modifiers changed from: package-private */
        public final void v() {
            ImageView imageView;
            TextView textView;
            setOrientation(TabLayout.this.B ^ true ? 1 : 0);
            if (this.h == null && this.i == null) {
                textView = this.f2384c;
                imageView = this.f2385d;
            } else {
                textView = this.h;
                imageView = this.i;
            }
            w(textView, imageView);
        }
    }

    public static class j implements d {

        /* renamed from: a  reason: collision with root package name */
        private final ViewPager f2388a;

        public j(ViewPager viewPager) {
            this.f2388a = viewPager;
        }

        public void a(g gVar) {
        }

        public void b(g gVar) {
            this.f2388a.setCurrentItem(gVar.f());
        }

        public void c(g gVar) {
        }
    }

    public TabLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, c.b.a.b.b.tabStyle);
    }

    /* JADX INFO: finally extract failed */
    public TabLayout(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        this.f2360b = new ArrayList<>();
        this.f2362d = new RectF();
        this.s = Integer.MAX_VALUE;
        this.F = new ArrayList<>();
        this.O = new b.f.k.f(12);
        setHorizontalScrollBarEnabled(false);
        f fVar = new f(context);
        this.e = fVar;
        super.addView(fVar, 0, new FrameLayout.LayoutParams(-2, -1));
        TypedArray k2 = com.google.android.material.internal.g.k(context, attributeSet, l.TabLayout, i2, k.Widget_Design_TabLayout, l.TabLayout_tabTextAppearance);
        if (getBackground() instanceof ColorDrawable) {
            c.b.a.b.c0.g gVar = new c.b.a.b.c0.g();
            gVar.U(ColorStateList.valueOf(((ColorDrawable) getBackground()).getColor()));
            gVar.L(context);
            gVar.T(s.s(this));
            s.h0(this, gVar);
        }
        this.e.g(k2.getDimensionPixelSize(l.TabLayout_tabIndicatorHeight, -1));
        this.e.f(k2.getColor(l.TabLayout_tabIndicatorColor, 0));
        setSelectedTabIndicator(c.b.a.b.z.c.d(context, k2, l.TabLayout_tabIndicator));
        setSelectedTabIndicatorGravity(k2.getInt(l.TabLayout_tabIndicatorGravity, 0));
        setTabIndicatorFullWidth(k2.getBoolean(l.TabLayout_tabIndicatorFullWidth, true));
        int dimensionPixelSize = k2.getDimensionPixelSize(l.TabLayout_tabPadding, 0);
        this.i = dimensionPixelSize;
        this.h = dimensionPixelSize;
        this.g = dimensionPixelSize;
        this.f = dimensionPixelSize;
        this.f = k2.getDimensionPixelSize(l.TabLayout_tabPaddingStart, dimensionPixelSize);
        this.g = k2.getDimensionPixelSize(l.TabLayout_tabPaddingTop, this.g);
        this.h = k2.getDimensionPixelSize(l.TabLayout_tabPaddingEnd, this.h);
        this.i = k2.getDimensionPixelSize(l.TabLayout_tabPaddingBottom, this.i);
        int resourceId = k2.getResourceId(l.TabLayout_tabTextAppearance, k.TextAppearance_Design_Tab);
        this.j = resourceId;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(resourceId, b.a.j.TextAppearance);
        try {
            this.p = (float) obtainStyledAttributes.getDimensionPixelSize(b.a.j.TextAppearance_android_textSize, 0);
            this.k = c.b.a.b.z.c.a(context, obtainStyledAttributes, b.a.j.TextAppearance_android_textColor);
            obtainStyledAttributes.recycle();
            if (k2.hasValue(l.TabLayout_tabTextColor)) {
                this.k = c.b.a.b.z.c.a(context, k2, l.TabLayout_tabTextColor);
            }
            if (k2.hasValue(l.TabLayout_tabSelectedTextColor)) {
                this.k = m(this.k.getDefaultColor(), k2.getColor(l.TabLayout_tabSelectedTextColor, 0));
            }
            this.l = c.b.a.b.z.c.a(context, k2, l.TabLayout_tabIconTint);
            this.o = com.google.android.material.internal.h.c(k2.getInt(l.TabLayout_tabIconTintMode, -1), (PorterDuff.Mode) null);
            this.m = c.b.a.b.z.c.a(context, k2, l.TabLayout_tabRippleColor);
            this.y = k2.getInt(l.TabLayout_tabIndicatorAnimationDuration, 300);
            this.t = k2.getDimensionPixelSize(l.TabLayout_tabMinWidth, -1);
            this.u = k2.getDimensionPixelSize(l.TabLayout_tabMaxWidth, -1);
            this.r = k2.getResourceId(l.TabLayout_tabBackground, 0);
            this.w = k2.getDimensionPixelSize(l.TabLayout_tabContentStart, 0);
            this.A = k2.getInt(l.TabLayout_tabMode, 1);
            this.x = k2.getInt(l.TabLayout_tabGravity, 0);
            this.B = k2.getBoolean(l.TabLayout_tabInlineLabel, false);
            this.D = k2.getBoolean(l.TabLayout_tabUnboundedRipple, false);
            k2.recycle();
            Resources resources = getResources();
            this.q = (float) resources.getDimensionPixelSize(c.b.a.b.d.design_tab_text_size_2line);
            this.v = resources.getDimensionPixelSize(c.b.a.b.d.design_tab_scrollable_min_width);
            j();
        } catch (Throwable th) {
            obtainStyledAttributes.recycle();
            throw th;
        }
    }

    private void A(int i2) {
        i iVar = (i) this.e.getChildAt(i2);
        this.e.removeViewAt(i2);
        if (iVar != null) {
            iVar.o();
            this.O.a(iVar);
        }
        requestLayout();
    }

    private void H(ViewPager viewPager, boolean z2, boolean z3) {
        ViewPager viewPager2 = this.I;
        if (viewPager2 != null) {
            h hVar = this.L;
            if (hVar != null) {
                viewPager2.J(hVar);
            }
            b bVar = this.M;
            if (bVar != null) {
                this.I.I(bVar);
            }
        }
        c cVar = this.G;
        if (cVar != null) {
            z(cVar);
            this.G = null;
        }
        if (viewPager != null) {
            this.I = viewPager;
            if (this.L == null) {
                this.L = new h(this);
            }
            this.L.d();
            viewPager.c(this.L);
            j jVar = new j(viewPager);
            this.G = jVar;
            b(jVar);
            androidx.viewpager.widget.a adapter = viewPager.getAdapter();
            if (adapter != null) {
                D(adapter, z2);
            }
            if (this.M == null) {
                this.M = new b();
            }
            this.M.b(z2);
            viewPager.b(this.M);
            E(viewPager.getCurrentItem(), 0.0f, true);
        } else {
            this.I = null;
            D((androidx.viewpager.widget.a) null, false);
        }
        this.N = z3;
    }

    private void I() {
        int size = this.f2360b.size();
        for (int i2 = 0; i2 < size; i2++) {
            this.f2360b.get(i2).r();
        }
    }

    private void J(LinearLayout.LayoutParams layoutParams) {
        float f2;
        if (this.A == 1 && this.x == 0) {
            layoutParams.width = 0;
            f2 = 1.0f;
        } else {
            layoutParams.width = -2;
            f2 = 0.0f;
        }
        layoutParams.weight = f2;
    }

    private void f(a aVar) {
        g v2 = v();
        CharSequence charSequence = aVar.f2389b;
        if (charSequence != null) {
            v2.q(charSequence);
        }
        Drawable drawable = aVar.f2390c;
        if (drawable != null) {
            v2.o(drawable);
        }
        int i2 = aVar.f2391d;
        if (i2 != 0) {
            v2.m(i2);
        }
        if (!TextUtils.isEmpty(aVar.getContentDescription())) {
            v2.l(aVar.getContentDescription());
        }
        c(v2);
    }

    private void g(g gVar) {
        i iVar = gVar.h;
        iVar.setSelected(false);
        iVar.setActivated(false);
        this.e.addView(iVar, gVar.f(), n());
    }

    private int getDefaultHeight() {
        int size = this.f2360b.size();
        boolean z2 = false;
        int i2 = 0;
        while (true) {
            if (i2 < size) {
                g gVar = this.f2360b.get(i2);
                if (gVar != null && gVar.e() != null && !TextUtils.isEmpty(gVar.h())) {
                    z2 = true;
                    break;
                }
                i2++;
            } else {
                break;
            }
        }
        return (!z2 || this.B) ? 48 : 72;
    }

    private int getTabMinWidth() {
        int i2 = this.t;
        if (i2 != -1) {
            return i2;
        }
        int i3 = this.A;
        if (i3 == 0 || i3 == 2) {
            return this.v;
        }
        return 0;
    }

    private int getTabScrollRange() {
        return Math.max(0, ((this.e.getWidth() - getWidth()) - getPaddingLeft()) - getPaddingRight());
    }

    private void h(View view) {
        if (view instanceof a) {
            f((a) view);
            return;
        }
        throw new IllegalArgumentException("Only TabItem instances can be added to TabLayout");
    }

    private void i(int i2) {
        if (i2 != -1) {
            if (getWindowToken() == null || !s.L(this) || this.e.c()) {
                E(i2, 0.0f, true);
                return;
            }
            int scrollX = getScrollX();
            int k2 = k(i2, 0.0f);
            if (scrollX != k2) {
                t();
                this.H.setIntValues(new int[]{scrollX, k2});
                this.H.start();
            }
            this.e.a(i2, this.y);
        }
    }

    private void j() {
        int i2 = this.A;
        s.r0(this.e, (i2 == 0 || i2 == 2) ? Math.max(0, this.w - this.f) : 0, 0, 0, 0);
        int i3 = this.A;
        if (i3 == 0) {
            this.e.setGravity(8388611);
        } else if (i3 == 1 || i3 == 2) {
            this.e.setGravity(1);
        }
        K(true);
    }

    private int k(int i2, float f2) {
        int i3 = this.A;
        int i4 = 0;
        if (i3 != 0 && i3 != 2) {
            return 0;
        }
        View childAt = this.e.getChildAt(i2);
        int i5 = i2 + 1;
        View childAt2 = i5 < this.e.getChildCount() ? this.e.getChildAt(i5) : null;
        int width = childAt != null ? childAt.getWidth() : 0;
        if (childAt2 != null) {
            i4 = childAt2.getWidth();
        }
        int left = (childAt.getLeft() + (width / 2)) - (getWidth() / 2);
        int i6 = (int) (((float) (width + i4)) * 0.5f * f2);
        return s.x(this) == 0 ? left + i6 : left - i6;
    }

    private void l(g gVar, int i2) {
        gVar.p(i2);
        this.f2360b.add(i2, gVar);
        int size = this.f2360b.size();
        while (true) {
            i2++;
            if (i2 < size) {
                this.f2360b.get(i2).p(i2);
            } else {
                return;
            }
        }
    }

    private static ColorStateList m(int i2, int i3) {
        return new ColorStateList(new int[][]{HorizontalScrollView.SELECTED_STATE_SET, HorizontalScrollView.EMPTY_STATE_SET}, new int[]{i3, i2});
    }

    private LinearLayout.LayoutParams n() {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -1);
        J(layoutParams);
        return layoutParams;
    }

    private i p(g gVar) {
        b.f.k.e<i> eVar = this.O;
        i b2 = eVar != null ? eVar.b() : null;
        if (b2 == null) {
            b2 = new i(getContext());
        }
        b2.setTab(gVar);
        b2.setFocusable(true);
        b2.setMinimumWidth(getTabMinWidth());
        b2.setContentDescription(TextUtils.isEmpty(gVar.f2378c) ? gVar.f2377b : gVar.f2378c);
        return b2;
    }

    private void q(g gVar) {
        for (int size = this.F.size() - 1; size >= 0; size--) {
            this.F.get(size).c(gVar);
        }
    }

    private void r(g gVar) {
        for (int size = this.F.size() - 1; size >= 0; size--) {
            this.F.get(size).b(gVar);
        }
    }

    private void s(g gVar) {
        for (int size = this.F.size() - 1; size >= 0; size--) {
            this.F.get(size).a(gVar);
        }
    }

    private void setSelectedTabView(int i2) {
        int childCount = this.e.getChildCount();
        if (i2 < childCount) {
            int i3 = 0;
            while (i3 < childCount) {
                View childAt = this.e.getChildAt(i3);
                boolean z2 = true;
                childAt.setSelected(i3 == i2);
                if (i3 != i2) {
                    z2 = false;
                }
                childAt.setActivated(z2);
                i3++;
            }
        }
    }

    private void t() {
        if (this.H == null) {
            ValueAnimator valueAnimator = new ValueAnimator();
            this.H = valueAnimator;
            valueAnimator.setInterpolator(c.b.a.b.m.a.f1875b);
            this.H.setDuration((long) this.y);
            this.H.addUpdateListener(new a());
        }
    }

    public void B(g gVar) {
        C(gVar, true);
    }

    public void C(g gVar, boolean z2) {
        g gVar2 = this.f2361c;
        if (gVar2 != gVar) {
            int f2 = gVar != null ? gVar.f() : -1;
            if (z2) {
                if ((gVar2 == null || gVar2.f() == -1) && f2 != -1) {
                    E(f2, 0.0f, true);
                } else {
                    i(f2);
                }
                if (f2 != -1) {
                    setSelectedTabView(f2);
                }
            }
            this.f2361c = gVar;
            if (gVar2 != null) {
                s(gVar2);
            }
            if (gVar != null) {
                r(gVar);
            }
        } else if (gVar2 != null) {
            q(gVar);
            i(gVar.f());
        }
    }

    /* access modifiers changed from: package-private */
    public void D(androidx.viewpager.widget.a aVar, boolean z2) {
        DataSetObserver dataSetObserver;
        androidx.viewpager.widget.a aVar2 = this.J;
        if (!(aVar2 == null || (dataSetObserver = this.K) == null)) {
            aVar2.o(dataSetObserver);
        }
        this.J = aVar;
        if (z2 && aVar != null) {
            if (this.K == null) {
                this.K = new e();
            }
            aVar.i(this.K);
        }
        w();
    }

    public void E(int i2, float f2, boolean z2) {
        F(i2, f2, z2, true);
    }

    public void F(int i2, float f2, boolean z2, boolean z3) {
        int round = Math.round(((float) i2) + f2);
        if (round >= 0 && round < this.e.getChildCount()) {
            if (z3) {
                this.e.e(i2, f2);
            }
            ValueAnimator valueAnimator = this.H;
            if (valueAnimator != null && valueAnimator.isRunning()) {
                this.H.cancel();
            }
            scrollTo(k(i2, f2), 0);
            if (z2) {
                setSelectedTabView(round);
            }
        }
    }

    public void G(ViewPager viewPager, boolean z2) {
        H(viewPager, z2, false);
    }

    /* access modifiers changed from: package-private */
    public void K(boolean z2) {
        for (int i2 = 0; i2 < this.e.getChildCount(); i2++) {
            View childAt = this.e.getChildAt(i2);
            childAt.setMinimumWidth(getTabMinWidth());
            J((LinearLayout.LayoutParams) childAt.getLayoutParams());
            if (z2) {
                childAt.requestLayout();
            }
        }
    }

    public void addView(View view) {
        h(view);
    }

    public void addView(View view, int i2) {
        h(view);
    }

    public void addView(View view, int i2, ViewGroup.LayoutParams layoutParams) {
        h(view);
    }

    public void addView(View view, ViewGroup.LayoutParams layoutParams) {
        h(view);
    }

    @Deprecated
    public void b(c cVar) {
        if (!this.F.contains(cVar)) {
            this.F.add(cVar);
        }
    }

    public void c(g gVar) {
        e(gVar, this.f2360b.isEmpty());
    }

    public void d(g gVar, int i2, boolean z2) {
        if (gVar.g == this) {
            l(gVar, i2);
            g(gVar);
            if (z2) {
                gVar.k();
                return;
            }
            return;
        }
        throw new IllegalArgumentException("Tab belongs to a different TabLayout.");
    }

    public void e(g gVar, boolean z2) {
        d(gVar, this.f2360b.size(), z2);
    }

    public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return generateDefaultLayoutParams();
    }

    public int getSelectedTabPosition() {
        g gVar = this.f2361c;
        if (gVar != null) {
            return gVar.f();
        }
        return -1;
    }

    public int getTabCount() {
        return this.f2360b.size();
    }

    public int getTabGravity() {
        return this.x;
    }

    public ColorStateList getTabIconTint() {
        return this.l;
    }

    public int getTabIndicatorGravity() {
        return this.z;
    }

    /* access modifiers changed from: package-private */
    public int getTabMaxWidth() {
        return this.s;
    }

    public int getTabMode() {
        return this.A;
    }

    public ColorStateList getTabRippleColor() {
        return this.m;
    }

    public Drawable getTabSelectedIndicator() {
        return this.n;
    }

    public ColorStateList getTabTextColors() {
        return this.k;
    }

    /* access modifiers changed from: protected */
    public g o() {
        g b2 = P.b();
        return b2 == null ? new g() : b2;
    }

    /* access modifiers changed from: protected */
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        c.b.a.b.c0.h.e(this);
        if (this.I == null) {
            ViewParent parent = getParent();
            if (parent instanceof ViewPager) {
                H((ViewPager) parent, true, true);
            }
        }
    }

    /* access modifiers changed from: protected */
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (this.N) {
            setupWithViewPager((ViewPager) null);
            this.N = false;
        }
    }

    /* access modifiers changed from: protected */
    public void onDraw(Canvas canvas) {
        for (int i2 = 0; i2 < this.e.getChildCount(); i2++) {
            View childAt = this.e.getChildAt(i2);
            if (childAt instanceof i) {
                ((i) childAt).j(canvas);
            }
        }
        super.onDraw(canvas);
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x0070, code lost:
        if (r0 != 2) goto L_0x008a;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x007b, code lost:
        if (r7.getMeasuredWidth() != getMeasuredWidth()) goto L_0x007d;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x007d, code lost:
        r4 = true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:26:0x0087, code lost:
        if (r7.getMeasuredWidth() < getMeasuredWidth()) goto L_0x007d;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void onMeasure(int r7, int r8) {
        /*
            r6 = this;
            android.content.Context r0 = r6.getContext()
            int r1 = r6.getDefaultHeight()
            float r0 = com.google.android.material.internal.h.a(r0, r1)
            int r0 = (int) r0
            int r1 = android.view.View.MeasureSpec.getMode(r8)
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r3 = 1073741824(0x40000000, float:2.0)
            r4 = 0
            r5 = 1
            if (r1 == r2) goto L_0x002b
            if (r1 == 0) goto L_0x001c
            goto L_0x003e
        L_0x001c:
            int r8 = r6.getPaddingTop()
            int r0 = r0 + r8
            int r8 = r6.getPaddingBottom()
            int r0 = r0 + r8
            int r8 = android.view.View.MeasureSpec.makeMeasureSpec(r0, r3)
            goto L_0x003e
        L_0x002b:
            int r1 = r6.getChildCount()
            if (r1 != r5) goto L_0x003e
            int r1 = android.view.View.MeasureSpec.getSize(r8)
            if (r1 < r0) goto L_0x003e
            android.view.View r1 = r6.getChildAt(r4)
            r1.setMinimumHeight(r0)
        L_0x003e:
            int r0 = android.view.View.MeasureSpec.getSize(r7)
            int r1 = android.view.View.MeasureSpec.getMode(r7)
            if (r1 == 0) goto L_0x005c
            int r1 = r6.u
            if (r1 <= 0) goto L_0x004d
            goto L_0x005a
        L_0x004d:
            float r0 = (float) r0
            android.content.Context r1 = r6.getContext()
            r2 = 56
            float r1 = com.google.android.material.internal.h.a(r1, r2)
            float r0 = r0 - r1
            int r1 = (int) r0
        L_0x005a:
            r6.s = r1
        L_0x005c:
            super.onMeasure(r7, r8)
            int r7 = r6.getChildCount()
            if (r7 != r5) goto L_0x00aa
            android.view.View r7 = r6.getChildAt(r4)
            int r0 = r6.A
            if (r0 == 0) goto L_0x007f
            if (r0 == r5) goto L_0x0073
            r1 = 2
            if (r0 == r1) goto L_0x007f
            goto L_0x008a
        L_0x0073:
            int r0 = r7.getMeasuredWidth()
            int r1 = r6.getMeasuredWidth()
            if (r0 == r1) goto L_0x008a
        L_0x007d:
            r4 = 1
            goto L_0x008a
        L_0x007f:
            int r0 = r7.getMeasuredWidth()
            int r1 = r6.getMeasuredWidth()
            if (r0 >= r1) goto L_0x008a
            goto L_0x007d
        L_0x008a:
            if (r4 == 0) goto L_0x00aa
            int r0 = r6.getPaddingTop()
            int r1 = r6.getPaddingBottom()
            int r0 = r0 + r1
            android.view.ViewGroup$LayoutParams r1 = r7.getLayoutParams()
            int r1 = r1.height
            int r8 = android.widget.HorizontalScrollView.getChildMeasureSpec(r8, r0, r1)
            int r0 = r6.getMeasuredWidth()
            int r0 = android.view.View.MeasureSpec.makeMeasureSpec(r0, r3)
            r7.measure(r0, r8)
        L_0x00aa:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.tabs.TabLayout.onMeasure(int, int):void");
    }

    public void setElevation(float f2) {
        super.setElevation(f2);
        c.b.a.b.c0.h.d(this, f2);
    }

    public void setInlineLabel(boolean z2) {
        if (this.B != z2) {
            this.B = z2;
            for (int i2 = 0; i2 < this.e.getChildCount(); i2++) {
                View childAt = this.e.getChildAt(i2);
                if (childAt instanceof i) {
                    ((i) childAt).v();
                }
            }
            j();
        }
    }

    public void setInlineLabelResource(int i2) {
        setInlineLabel(getResources().getBoolean(i2));
    }

    @Deprecated
    public void setOnTabSelectedListener(c cVar) {
        c cVar2 = this.E;
        if (cVar2 != null) {
            z(cVar2);
        }
        this.E = cVar;
        if (cVar != null) {
            b(cVar);
        }
    }

    @Deprecated
    public void setOnTabSelectedListener(d dVar) {
        setOnTabSelectedListener((c) dVar);
    }

    /* access modifiers changed from: package-private */
    public void setScrollAnimatorListener(Animator.AnimatorListener animatorListener) {
        t();
        this.H.addListener(animatorListener);
    }

    public void setSelectedTabIndicator(int i2) {
        setSelectedTabIndicator(i2 != 0 ? b.a.k.a.a.d(getContext(), i2) : null);
    }

    public void setSelectedTabIndicator(Drawable drawable) {
        if (this.n != drawable) {
            this.n = drawable;
            s.W(this.e);
        }
    }

    public void setSelectedTabIndicatorColor(int i2) {
        this.e.f(i2);
    }

    public void setSelectedTabIndicatorGravity(int i2) {
        if (this.z != i2) {
            this.z = i2;
            s.W(this.e);
        }
    }

    @Deprecated
    public void setSelectedTabIndicatorHeight(int i2) {
        this.e.g(i2);
    }

    public void setTabGravity(int i2) {
        if (this.x != i2) {
            this.x = i2;
            j();
        }
    }

    public void setTabIconTint(ColorStateList colorStateList) {
        if (this.l != colorStateList) {
            this.l = colorStateList;
            I();
        }
    }

    public void setTabIconTintResource(int i2) {
        setTabIconTint(b.a.k.a.a.c(getContext(), i2));
    }

    public void setTabIndicatorFullWidth(boolean z2) {
        this.C = z2;
        s.W(this.e);
    }

    public void setTabMode(int i2) {
        if (i2 != this.A) {
            this.A = i2;
            j();
        }
    }

    public void setTabRippleColor(ColorStateList colorStateList) {
        if (this.m != colorStateList) {
            this.m = colorStateList;
            for (int i2 = 0; i2 < this.e.getChildCount(); i2++) {
                View childAt = this.e.getChildAt(i2);
                if (childAt instanceof i) {
                    ((i) childAt).u(getContext());
                }
            }
        }
    }

    public void setTabRippleColorResource(int i2) {
        setTabRippleColor(b.a.k.a.a.c(getContext(), i2));
    }

    public void setTabTextColors(ColorStateList colorStateList) {
        if (this.k != colorStateList) {
            this.k = colorStateList;
            I();
        }
    }

    @Deprecated
    public void setTabsFromPagerAdapter(androidx.viewpager.widget.a aVar) {
        D(aVar, false);
    }

    public void setUnboundedRipple(boolean z2) {
        if (this.D != z2) {
            this.D = z2;
            for (int i2 = 0; i2 < this.e.getChildCount(); i2++) {
                View childAt = this.e.getChildAt(i2);
                if (childAt instanceof i) {
                    ((i) childAt).u(getContext());
                }
            }
        }
    }

    public void setUnboundedRippleResource(int i2) {
        setUnboundedRipple(getResources().getBoolean(i2));
    }

    public void setupWithViewPager(ViewPager viewPager) {
        G(viewPager, true);
    }

    public boolean shouldDelayChildPressedState() {
        return getTabScrollRange() > 0;
    }

    public g u(int i2) {
        if (i2 < 0 || i2 >= getTabCount()) {
            return null;
        }
        return this.f2360b.get(i2);
    }

    public g v() {
        g o2 = o();
        o2.g = this;
        o2.h = p(o2);
        return o2;
    }

    /* access modifiers changed from: package-private */
    public void w() {
        int currentItem;
        y();
        androidx.viewpager.widget.a aVar = this.J;
        if (aVar != null) {
            int c2 = aVar.c();
            for (int i2 = 0; i2 < c2; i2++) {
                g v2 = v();
                v2.q(this.J.e(i2));
                e(v2, false);
            }
            ViewPager viewPager = this.I;
            if (viewPager != null && c2 > 0 && (currentItem = viewPager.getCurrentItem()) != getSelectedTabPosition() && currentItem < getTabCount()) {
                B(u(currentItem));
            }
        }
    }

    /* access modifiers changed from: protected */
    public boolean x(g gVar) {
        return P.a(gVar);
    }

    public void y() {
        for (int childCount = this.e.getChildCount() - 1; childCount >= 0; childCount--) {
            A(childCount);
        }
        Iterator<g> it = this.f2360b.iterator();
        while (it.hasNext()) {
            g next = it.next();
            it.remove();
            next.j();
            x(next);
        }
        this.f2361c = null;
    }

    @Deprecated
    public void z(c cVar) {
        this.F.remove(cVar);
    }
}
